clearPanels();
fl.runScript("${jsflFile}");


// Save compile output
fl.outputPanel.save("${outputFile}", false, true);
// Save compiler errors for versions of the IDE that support it
if(getMajorVersion() >= 9)
{
	fl.compilerErrors.save("${outputFile}", true, true);
}


FLfile.remove("${workingFile}");

if(${closeWhenFinished})
{
	fl.quit();
}



function getMajorVersion()
{
	// Since the fl.version property wasn't around prior to MX2004 (aka Flash 7),
	// we can't tell if it's anything lower than 7 - hence we'll just default to that
	var retVal = 7;
	
	// Pull out the major version from strings such as 'WIN 10,0,2,566'
	var majorRegEx = /^\w+ (\d{1,2}),[\d,]+$/
	var matches = fl.version.match(majorRegEx);
	
	// We should have 2 matches - the full match and the group for the major version
	if(matches != null && matches.length == 2)
	{
		retVal = matches[1];
	}
	
	return retVal;
}



function clearPanels()
{
	fl.outputPanel.clear();
	
	// The compilerErrors panel didn't exist before v9
	if(getMajorVersion() >= 9)
	{
		fl.compilerErrors.clear();
	}
}



function log(msg)
{
	fl.outputPanel.trace(msg);
}



function error(msg)
{
	fl.outputPanel.trace("**Error** " + msg);
}
